<?php 
//无需修改本页任何内容，除非你十分了解并足够把握
$ca="chalide"; //系统字段前缀及表名称前缀 不建议修改
$pd="1`字段之一等于|5`字段之一等于(低性能)|2`字段之一开始|3`字段之一结尾|4`字段之一包含";
$el="2`开发模式|1`正常查询";
$th = date("YmdHis"); $mo = date("Y-m-d H:i:s"); $du = date("Ymd");
$iq = $_SERVER['REMOTE_ADDR'];
$sr = md5($du.$iq);
$nx = explode('.',$_SERVER['HTTP_HOST']);
$fa = $nx[0]; //域名(表)获取
$ne = "./inc/conn_{$fa}_data.php";
if (!file_exists($ne)){
file_put_contents($ne, json_encode($pubs));
}
if (file_exists($ne)){
$vs = file_get_contents($ne);
$pubs = json_decode($vs,true);
}
foreach ($pubs as $ti=>$val) $$ti = $val; //调用
if (!$dbhost && !$dbuser){ exit("sj:".$th); }
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport);
if (!$conn){ $ov="sqls"; $dr = "". mysqli_connect_error(); }
mysql_query("set zi '$dbcode'");
$ig = "./inc/conn_{$fa}_json.php";
if (!file_exists($ig)){
$site["lm"]=$th; //首次生成 自己更新参数
file_put_contents($ig, json_encode($site));
}
if (file_exists($ig)){
$json = file_get_contents($ig);
$site = json_decode($json,true);
}
if(stristr("-2-",$site["nd"])){ $site["lm"]=$th;}
foreach ($site as $ti=>$val) $$ti = $val; //调用
if(stristr("-1-7-X-x-",$dp)){ $lc="onBlur";}else{ $lc="onInput";}
$dt = "./inc/conn_{$fa}_user.php";
if (!file_exists($dt)){
ra($dt,$dlpass);
}
$rf = "./inc/conn_{$fa}_duan.php";
if (!file_exists($rf)){
$gl = "DESCRIBE `{$en}`";
$ye = mysqli_query($conn, $gl);
$duan=array(); $fr=0;
if (!$ye){
 $ov=="sqls";
$duan["error"] = "数据库表{$en}异常：".mysqli_error($conn);
}else{
while($err = $ye->fetch_assoc()){
$Field = $err["Field"];
$duan[$Field] = $Field; $fr++;
}
}
file_put_contents($rf, json_encode($duan));
}
$vs = file_get_contents($rf);
$duan = json_decode($vs,true);
$uk = array();
$uk["ls"] = "多条件支持，各条件三横开头结尾分开;数据库<b>得有这些字段</b>，建议索引字段";
$uk["title"] = "设置网站标题,例:某某单位某某查询系统。";
$uk["copyr"] = "设置底部版权文字,建议使用单位简称。";
$uk["lu"] = "设置底部版权连接,推荐填写单位官网网址。";
$uk["nd"] = $el;
$uk["ro"] = "分页：每页显示数量，推荐5,10,20";
$uk["ee"] = "单元格字数，超过则先折叠";
$uk["ni"] = "结果显示最大页数：防止全部显示，注意下个参数为9也有效";
$uk["dp"] = "1等于2开始3结尾4包含";
$uk["bj"] = "隐藏列，三横开头结尾分开;数据存在財有效";
$uk["yp"] = "图片列，三横开头结尾分开;数据存在財有效";
$uk["tv"] = "网址列，三横开头结尾分开;数据存在財有效";
$uk["en"] = "注意：清空表将清空该表所有数据，请谨慎操作！";
$uk["rr"] = "查询页面说明文字在这个文件修改";
$uk["ou"] = "允许上传文件大小，单位KB 4096 = 4MB";
$uk["datedir"] = "上传存储路径,不懂别修改";
$uk["dluser"] = "登录账户,格式为邮件,修改后会退出重新登录";
$uk["lm"] = "调试开发期间，修改cssjs后更新这个时间可去jscss文件缓存";
$tb = array();
$tb["dbhost"] = "数据库地址";
$tb["dbuser"] = "数据库账号";
$tb["dbpass"] = "数据库密码";
$tb["dbname"] = "数据库名称";
$tb["dbport"] = "数据库端口号";
$tb["dbcode"] = "数据库编码";
$tb["en"] = "数据库表名";
$tu = explode("---",$ls);
$a = 0;
$al = ""; $dn = "";$ha="";$rc="";
$eh = "<div id=\"rk\">";
foreach ($tu as $ja) {
if(strlen($ja)>0){
$a++;
$ha .="<option value=\"{$ja}\">$ja</option>\r\n";
if(strlen($al)>0){
$al .= ",".$ja;
$rc .= ",\"|\",`{$ja}`";
$dn .= "或".$ja;
$ic .= "".$ja."|";
$py .= " OR `{$ja}` LIKE '%{ts}%'";
}else{
$al = "".$ja;
$rc = "`{$ja}`";
$dn = "".$ja;
$ic = "|{$ja}|";
$py .= " WHERE `{$ja}` LIKE '%{ts}%'";
}
}
}

function af($fu,$os){
$ae =file_get_contents($fu);
return json_decode($ae,true);
}
function ai(){
global $conn,$en;
$ze = "";
$tables = mysqli_query($conn,"show tables");
while($row = mysqli_fetch_row($tables)){
$k++; $rt=$row[0]; $ze .= "{$rt}`{$rt}|";
}
if($k<1){ $ze = "Null`无表可选,请先建表,导入数据|";}else{$ze=Trim($ze); }
return nb($ze,"it",$en);
}
function nb($es,$ys,$rn){
if(!stristr($es,"`") || !stristr($es,"|")) return "<option value=\"\">无效参数</option>";
$ew = explode("|",$es);
$dox="<!-- $rn --><select name=\"$ys\" id=\"$ys\" class=\"cc\">\r\n";
foreach($ew as $tm){
$xa = explode("`",$tm); $cu = $xa[0]; $xv = $xa[1];
if("s".$rn=="s".$cu){$ly = " selected";}else{$ly = "";}
if(stristr($tm,"`")) $dox.="<option value=\"{$cu}\"{$ly}>$xv</option>\r\n";
}
return $dox."</select>\r\n";
}

function nf($dp,$al,$ts,$rc){
$sqs =array();
if($dp."_"=="4_"){
$sqs["lan"] = "WHERE `{$al}` LIKE '%{$ts}%'"; //模糊搜索
$sqs["ao"] = "<b>{$al}</b>包含<b>{$ts}</b>的结果";
}elseif($dp."_"=="5_"){ //精准查询
$sqs["lan"] = "WHERE `{$al}` LIKE '{$ts}'"; //等于关系
$sqs["ao"] = "<b>{$al}</b>等于<b>{$ts}</b>的结果";
}elseif($dp."_"=="1_"){ //精准查询
$sqs["lan"] = "WHERE `{$al}` = '{$ts}'"; //等于关系
$sqs["ao"] = "<b>{$al}</b>等于<b>{$ts}</b>的结果";
}elseif($dp."_"=="2_"){ //前查询
$sqs["lan"] = "WHERE `{$al}` LIKE '{$ts}%'"; //模糊搜索
$sqs["ao"] = "<b>{$al}</b>:<b>{$ts}</b>开头的结果";
}elseif($dp."_"=="3_"){ //后查询
$sqs["lan"] = "WHERE `{$al}` LIKE '%{$ts}'"; //模糊搜索
$sqs["ao"] = "<b>{$al}</b>:<b>{$ts}</b>结尾的结果";
}else{
$sqs["lan"] = "WHERE `{$al}` = '{$ts}'"; //默认:等于关系
$sqs["ao"] = "<b>{$al}</b>等于<b>{$ts}</b>的结果";
}
return $sqs;
}
function ra($dt,$dlpass){
global $fa,$iq,$th;
$sw = array();$sw["pass"]='<?php exit();?>';
$sw["ww"]=$th;
$sw["word"]=md5("Cha{$dlpass}li{$fa}im");$xt=json_encode($sw);
if(!file_exists($dt)){}
file_put_contents($dt, $xt);
}

function webalert($Key){
 $html="<script>\r\n";
 $html.="alert('".$Key."');\r\n";
 $html.="history.go(-1);\r\n";
 $html.="</script>";
 exit($html);
}
function ue($mn){
$mn = htmlspecialchars($mn);
return addslashes($mn); 
}
function charaget($data){
 if(!empty($data)){ 
 $fileType = mb_detect_encoding($data , array('GB2312','GBK','UTF-8','LATIN1','BIG5')) ; 
 if( $fileType != 'UTF-8'){ $data = mb_convert_encoding($data ,'UTF-8' , $fileType); } 
 } 
 return $data; 
}
function on($Key){
 $html ="<table cellspacing=\"0\">\r\n<tbody>";
 $html.="<tr><td data-label=\"查询提示\" class=\"l\">$Key</td></tr>";
 $html.="</tbody></table>";
 echo $html;
}
?>